package com.ross.web.transaction;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ross.web.dao.ProductDAO;
import com.ross.web.util.SessionLogout;

public class SearchProductAction extends ActionSupport {
	
	private List productList;
	private String query;
	ProductDAO productDAO;
	
	SessionLogout sessionLogout = new SessionLogout();
	public String setSearchProductAction(){
		
		if (sessionLogout.SessionExpired()) {
			addActionMessage("Session already expired");
			return "sessionExpired";
		}
		
		productDAO = new ProductDAO();
		
		productList = productDAO.getAllProduct();
		return SUCCESS;
	}
	
	public String searchProductAction(){
		
		if (sessionLogout.SessionExpired()) {
			addActionMessage("Session already expired");
			return "sessionExpired";
		}
		
		productDAO = new ProductDAO();
		productList = productDAO.getProductByName(query);
		
		return SUCCESS;
	}
	
	

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public List getProductList() {
		return productList;
	}

	public void setProductList(List productList) {
		this.productList = productList;
	}
	
	
}
